﻿<UserControl x:Class="XERP.Client.WPF.DBStoredImageMaintenance.Views.MainMaintenanceView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
             d:DesignHeight="600" d:DesignWidth="800"
             IsEnabled="{Binding Path=FormIsEnabled}" Loaded="UserControl_Loaded" 
             PreviewKeyUp="UserControl_PreviewKeyUp">

    <Grid Style="{StaticResource BaseGrid}">
        <Grid.RowDefinitions>
            <RowDefinition Height="50"></RowDefinition>
            <RowDefinition Height="550*"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="156"></ColumnDefinition>
            <ColumnDefinition Width="422*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <TextBlock Style="{StaticResource BaseHeader}"
            HorizontalAlignment="Left" Grid.Column="1" Text="Menu Icon Maintenance Form"
            FontSize="13" Margin="138,10,0,5" >
        </TextBlock>
        <StackPanel Style="{StaticResource BaseStackPanel}"
            Orientation="Vertical"  Width="271"  Height="50" Grid.ColumnSpan="2"
            HorizontalAlignment="Left" VerticalAlignment="Top">
            <Menu Style="{StaticResource BaseMenu}"
                IsMainMenu="True" Grid.ColumnSpan="2" Width="250" Height="20" 
                VerticalAlignment="Top" HorizontalAlignment="Left">
                <MenuItem Style="{StaticResource BaseMenuItem}" Header="_File">
                    <MenuItem Style="{StaticResource BaseMenuItem}" Header="_New">
                        <MenuItem Style="{StaticResource BaseMenuItem}" Name="mnuNewDBStoredImage" 
                                  Header="_New DBStoredImage" IsEnabled="{Binding AllowNew}">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <ei:CallMethodAction
                                    TargetObject="{Binding}"
                                    MethodName="NewDBStoredImageCommand"/>
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </MenuItem>
                    </MenuItem>
                    <MenuItem Style="{StaticResource BaseMenuItem}"  Header="_Save" Name="mnuSave"
                              Click="SaveMenuItem_Click" >

                    </MenuItem>
                    <MenuItem Style="{StaticResource BaseMenuItem}" Header="_Delete" >
                        <MenuItem Style="{StaticResource BaseMenuItem}" Header="_Delete DBStoredImage" 
                                  IsEnabled="{Binding AllowDelete}">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <ei:CallMethodAction
                                    TargetObject="{Binding}"
                                    MethodName="DeleteDBStoredImageCommand"/>
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </MenuItem>
                    </MenuItem>
                    <MenuItem Style="{StaticResource BaseMenuItem}" Header="_Exit" 
                              Command="Close"/>
                </MenuItem>
                <MenuItem Style="{StaticResource BaseMenuItem}" Header="_Edit">
                    <MenuItem Style="{StaticResource BaseMenuItem}" Header="_Clear">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <ei:CallMethodAction
                                TargetObject="{Binding}"
                                MethodName="ClearCommand"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </MenuItem>
                    <MenuItem Style="{StaticResource BaseMenuItem}" Header="_Refresh">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <ei:CallMethodAction
                                TargetObject="{Binding}"
                                MethodName="RefreshCommand"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </MenuItem>
                    <MenuItem Style="{StaticResource BaseMenuItem}" Header="_Cut" 
                              Command="Cut"/>
                    <MenuItem Style="{StaticResource BaseMenuItem}" Header="_Copy" 
                              Command="Copy"/>
                    <MenuItem Style="{StaticResource BaseMenuItem}" Header="_Paste" 
                              Command="Paste"/>
                </MenuItem>
                <MenuItem Style="{StaticResource BaseMenuItem}" Header="_Tools"/>
                <MenuItem Style="{StaticResource BaseMenuItem}" Header="_Actions"/>
                <MenuItem Style="{StaticResource BaseMenuItem}" Header="_Help"/>
            </Menu>
            <Menu  Style="{StaticResource BaseMenu}"
                IsMainMenu="True"  Width="270" Height="30" KeyboardNavigation.IsTabStop="False" 
                VerticalAlignment="Top" HorizontalAlignment="Left" Background="{x:Null}">
                <MenuItem Style="{StaticResource AddNewMenuItem}" Padding="0">
                    <MenuItem Header="_New DBStoredImage" 
                          IsEnabled="{Binding AllowNew}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <ei:CallMethodAction
                        TargetObject="{Binding}"
                        MethodName="NewDBStoredImageCommand"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </MenuItem>
                </MenuItem>
                <MenuItem Style="{StaticResource BaseMenuItem}" Click="SaveMenuItem_Click" >
                    <MenuItem.Header>
                        <Button Style="{StaticResource SaveButton}" Click="SaveMenuItem_Click">

                        </Button>
                    </MenuItem.Header>
                </MenuItem>
                <MenuItem Style="{StaticResource DeleteMenuItem}" Padding="0">
                    <MenuItem Style="{StaticResource BaseMenuItem}" Header="_Delete DBStoredImage" 
                          IsEnabled="{Binding AllowDelete}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <ei:CallMethodAction
                            TargetObject="{Binding}"
                            MethodName="DeleteDBStoredImageCommand"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </MenuItem>
                </MenuItem>
                <MenuItem Style="{StaticResource BaseMenuItem}">
                    <MenuItem.Header>
                        <Button Style="{StaticResource ClearButton}">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <ei:CallMethodAction
                                    TargetObject="{Binding}"
                                    MethodName="ClearCommand"/>
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </Button>
                    </MenuItem.Header>
                </MenuItem>
                <MenuItem Style="{StaticResource BaseMenuItem}">
                    <MenuItem.Header>
                        <Button Style="{StaticResource RefreshButton}">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <ei:CallMethodAction
                                TargetObject="{Binding}"
                                MethodName="RefreshCommand"/>
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </Button>
                    </MenuItem.Header>
                </MenuItem>
                <MenuItem Style="{StaticResource BaseMenuItem}" >
                    <MenuItem.Header>
                        <Button Style="{StaticResource CutButton}" Command="Cut"/>
                    </MenuItem.Header>
                </MenuItem>
                <MenuItem Style="{StaticResource BaseMenuItem}">
                    <MenuItem.Header>
                        <Button Style="{StaticResource CopyButton}" Command="Copy"/>
                    </MenuItem.Header>
                </MenuItem>
                <MenuItem  Style="{StaticResource BaseMenuItem}">
                    <MenuItem.Header>
                        <Button Style="{StaticResource PasteButton}" Command="Paste"/>
                    </MenuItem.Header>
                </MenuItem>
            </Menu>
        </StackPanel>
        <GridSplitter Style="{StaticResource BaseVerticalGridSplitter}" Grid.Row="1" Grid.Column="0"/>
        <ListBox Style="{StaticResource BaseListBox}" Grid.Row="1" Grid.Column="0" 
            ItemsSource="{Binding DBStoredImageList}"
            SelectedItem="{Binding SelectedDBStoredImage}"
            SelectionMode="Single">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Vertical">
                        <StackPanel Orientation="Horizontal">
                            <Image Height="16" Width="16">
                                <Image.Style>
                                    <Style>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding Path=IsValid}" Value="{x:Null}">
                                                <Setter Property="Image.Source" Value="/XERP.Client;component/Resources/valid.png"/>
                                            </DataTrigger>
                                            <DataTrigger Binding="{Binding Path=IsValid}" Value="0">
                                                <Setter Property="Image.Source" Value="/XERP.Client;component/Resources/valid.png"/>
                                            </DataTrigger>
                                            <DataTrigger Binding="{Binding Path=IsValid}" Value="1">
                                                <Setter Property="Image.Source" Value="/XERP.Client;component/Resources/error.ico" />
                                            </DataTrigger>
                                            <DataTrigger Binding="{Binding Path=IsValid}" Value="2">
                                                <Setter Property="Image.Source" Value="/XERP.Client;component/Resources/flag2.png" />
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Image.Style>
                            </Image>
                            <TextBlock Text="{Binding Path=ImageID}" >
                            </TextBlock>
                            <TextBlock Width="0"
                                Text="{Binding Path=IsValid}" Visibility="Hidden">
                            </TextBlock>
                        </StackPanel>
                        <TextBlock Style="{StaticResource BaseErrorBlock}" Height="Auto"
                                       Text="{Binding Path = NotValidMessage}"/>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>

        </ListBox>
        <TabControl Style="{StaticResource BaseTabControl}" Name="tabctrlMain" Grid.Column="1" Grid.Row="1">
            <TabItem  Style="{StaticResource BaseTabItem}" Name="tabDetail" Header="Detail">
                <ScrollViewer>
                    <Grid Style="{StaticResource BaseGrid}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="46"></RowDefinition>
                            <RowDefinition Height="657*"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="171"></ColumnDefinition>
                            <ColumnDefinition Width="246*"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <StackPanel Style="{StaticResource BaseStackPanel}" Grid.Row="0" 
                        Grid.ColumnSpan="2" HorizontalAlignment="Stretch" 
                        VerticalAlignment="Stretch" Orientation="Horizontal" >
                            <Button Style="{StaticResource BaseButton}" Content="Icon ID..." Width="108" Height="25" Margin="10" 
                            KeyboardNavigation.IsTabStop="False" >
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <ei:CallMethodAction
                                      TargetObject="{Binding}"
                                      MethodName="SearchCommand"/>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </Button>
                            <TextBox Style="{StaticResource BaseTextBox}"  Width="251" Height="20" 
                            Text="{Binding Path=SelectedDBStoredImage.ImageID, Mode=TwoWay}"
                            MaxLength= "{Binding DBStoredImageMaxFieldValueDictionary[ImageID]}" 
                            KeyboardNavigation.TabIndex="20" Name="txtKey"></TextBox>
                        </StackPanel>
                        <StackPanel Style="{StaticResource BaseStackPanel}"
                             HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
                            Orientation="Vertical" Grid.Row="1" Grid.Column="0" >
                            <TextBlock Style="{StaticResource BaseTextBlock}"
                                HorizontalAlignment="Right" VerticalAlignment="Top" Margin="8">Description:
                            </TextBlock>
                            <TextBlock Style="{StaticResource BaseTextBlock}"
                                HorizontalAlignment="Right" VerticalAlignment="Top" Margin="8">Notes:
                            </TextBlock>
                            <TextBlock Style="{StaticResource BaseTextBlock}"
                                HorizontalAlignment="Right" VerticalAlignment="Top" Margin="8,30,8,8">Icon Image:
                            </TextBlock>
                            <TextBox Style="{StaticResource BaseTextBox}" 
                                Width="0" Height="0"  Name="ghost"  KeyboardNavigation.IsTabStop="False"/>
                        </StackPanel>
                        <StackPanel Style="{StaticResource BaseStackPanel}"
                            Grid.Row="1" Grid.Column="1"
                            HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
                            Orientation="Vertical" IsEnabled="{Binding AllowEdit}">
                            <TextBox Style="{StaticResource BaseTextBox}"
                                HorizontalAlignment="Left" VerticalAlignment="Top" Margin="5" Width="250"
                                Text="{Binding Path=SelectedDBStoredImage.Description, Mode=TwoWay}"
                                MaxLength= "{Binding DBStoredImageMaxFieldValueDictionary[Description]}" 
                                KeyboardNavigation.TabIndex="30" BorderBrush="DimGray">
                            </TextBox>
                            <TextBox Style="{StaticResource BaseTextBox}" AcceptsReturn="True" TextWrapping="Wrap"
                                HorizontalAlignment="Left" VerticalAlignment="Top" Margin="5" Width="250"
                                Text="{Binding Path=SelectedDBStoredImage.Notes, Mode=TwoWay}"
                                MaxLength= "{Binding DBStoredImageMaxFieldValueDictionary[Notes]}" 
                                KeyboardNavigation.TabIndex="40" BorderBrush="DimGray" Height="41">
                            </TextBox>
                            <Image  Margin="5" HorizontalAlignment="Left" Height="50" Name="imgIcon" Stretch="Fill" Width="50" 
                                   Source="{Binding IconImage}" KeyboardNavigation.IsTabStop="False"/>
                            <Button Style="{StaticResource BaseButton}" Content="Replace/Get Icon..." Width="108" Height="25" Margin="5" 
                            KeyboardNavigation.IsTabStop="True" KeyboardNavigation.TabIndex="50" HorizontalAlignment="Left" Click="ReplaceGetIcon_Click">
                            </Button>
                        </StackPanel>
                    </Grid>
                </ScrollViewer>
            </TabItem>

        </TabControl>
    </Grid>
</UserControl>
